#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<sys/mman.h>
#include<errno.h>
#include<fcntl.h>
#include<unistd.h> 
#include<pthread.h>


struct STUDENT{
	char name[256];
	int id;
	int source;
};



int
main(int argc, char* args[])
{
	int fd;
	fd = open("mmap", O_RDONLY);
	if(fd < 0){
		perror("open error");
		exit(1);
	}
	
	struct STUDENT* mm = nullptr;

	mm = (STUDENT*) mmap(NULL, sizeof(STUDENT), PROT_READ, MAP_SHARED, fd, 0);
	if(mm == MAP_FAILED){
		perror("map error");
		exit(1);
	}
	printf("error not in there\n");
	while(1){
		printf("name is %s\n id is %d\n source is %d\n", mm -> name, mm -> id, mm -> source);
		sleep(2);
	}
			
	mnumap(mm, sizeof(student));
	return 0;
}
